<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="format-detection" content="telephone=no">
  <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" href="./css/font.css">
  <link rel="stylesheet" href="./css/xadmin.css">
  <script type="text/javascript" src="./static/js/plugin/jquery.min.js"></script>
  <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
  <script type="text/javascript" src="./js/xadmin.js"></script>
  <style>
    html, body {
      height: 100%;
      margin:0;padding:0;
      font-size: 12px;
    }
    div{
      -moz-box-sizing: border-box;  /*Firefox3.5+*/
      -webkit-box-sizing: border-box; /*Safari3.2+*/
      -o-box-sizing: border-box; /*Opera9.6*/
      -ms-box-sizing: border-box; /*IE8*/
      box-sizing: border-box; /*W3C标准(IE9+，Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/
    }
    .dHead {
      height:85px;
      width:100%;
      position: fixed;
      z-index:5;
      top:0;
      overflow-x: auto;
      padding: 10px;
    }
    .dBody {
      width:100%;
      overflow:auto;
      top:90px;
      position:absolute;
      z-index:10;
      bottom:5px;
    }
    .layui-btn-xstree {
      height: 35px;
      line-height: 35px;
      padding: 0px 5px;
      font-size: 12px;
    }
    .layui-table-cell{
      height:40px;
      line-height: 40px;
    }
  </style>
</head>

<body class="layui-layout-body">
<fieldset class="layui-elem-field">
  <div class="layui-field-box">
    <form class="layui-form" id="searchForm">
      <div class="layui-inline">
        <a class="layui-btn layui-btn-normal" data-type="addParent">添加主类目</a>
      </div>
      <div class="layui-inline">
        <a class="layui-btn layui-btn-normal" data-type="companyHome">企业首页标签</a>
      </div>
      <div class="layui-inline">
        <a class="layui-btn layui-btn-normal" data-type="hotSearch">热搜词管理</a>
      </div>
      <div class="layui-inline">
        <a class="layui-btn layui-btn-primary layui-btn-xs layui-btn-xstree"  onclick="openAll();">展开或折叠全部</a>
      </div>
    </form>
  </div>
</fieldset>
<div style="height: 100%">
  <div class="dBody">
    <table class="layui-hidden" id="treeTable" lay-filter="treeTable"></table>
    <script type="text/html" id="icon">
      {{#  if(d.icon != "" && d.icon != null){ }}
      <span id="image_{{d.id}}" ><img lay-event="imageimage" layer-pid="{{d.id}}" layer-src="{{d.icon}}" src="{{d.icon}}" style="width: 40px;"/></span>
      {{#  } else { }}
      <span ></span>
      {{#  } }}
    </script>
    <script type="text/html" id="homeIcon">
      {{#  if(d.home_icon != "" && d.home_icon != null){ }}
      <span id="home_icon_{{d.id}}" ><img lay-event="imagehome_icon" layer-pid="{{d.id}}" layer-src="{{d.home_icon}}" src="{{d.home_icon}}" style="width: 40px;"/></span>
      {{#  } else { }}
      <span ></span>
      {{#  } }}
    </script>
    <script type="text/html" id="barDemo">
      {{# if(d.pId == 0){ }}
      <a class="layui-btn layui-btn-xs" lay-event="add">添加子类目</a>
      <a class="layui-btn layui-btn-xs" lay-event="checkBusiness">查看商家列表</a>
      <a class="layui-btn layui-btn-xs" lay-event="checkCompany">查看企业列表</a>
      {{# } }}
      <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
      {{# if(d.pId != 0){ }}
      <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
      {{# } }}
    </script>
  </div>
</div>
<script>
    var editObj=null,ptable=null,treeGrid=null,tableId='treeTable',layer=null;
    layui.config({
        base: '/static/js/'
    }).extend({
        treeGrid:'treeGrid'
    }).use(['jquery','treeGrid','layer'], function(){
        var $=layui.jquery;
        treeGrid = layui.treeGrid;//很重要
        layer=layui.layer;
        ptable=treeGrid.render({
            id:tableId
            ,elem: '#'+tableId
            ,url:'/getCateList'
            ,cellMinWidth: 100
            ,idField:'id'//必須字段
            ,treeId:'id'//树形id字段名称
            ,treeUpId:'pId'//树形父id字段名称
            ,treeShowName:'name'//以树形式显示的字段
            ,heightRemove:[".dHead",10]//不计算的高度,表格设定的是固定高度，此项不生效
            ,height:'100%'
            ,loading:true
            ,method:'post'
            ,isPage:false
            ,isOpenDefault:false//节点默认是展开还是折叠【默认展开】
            ,cols: [[
                {field:'id', title: 'id'}
                ,{field:'name', title: '名称'},
                {width:450,title: '操作', align:'center',toolbar: '#barDemo'}
            ]]
            ,parseData:function (res) {//数据加载后回调
                return res;
            }
        });

    });
</script>
</body>
</html>